{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 解析 ONNX GraphProto"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import set_env\n",
    "from tvm.relay.frontend.onnx import GraphProto"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[0;31mInit signature:\u001b[0m \u001b[0mGraphProto\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfreeze_params\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mop_type_dict\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mDocstring:\u001b[0m     \n",
      "A helper class for handling Relay expression copying from pb2.GraphProto.\n",
      "Definition: https://github.com/onnx/onnx/blob/main/onnx/onnx.proto\n",
      "\n",
      "    Parameters\n",
      "----------\n",
      "shape : dict of str to tuple, optional\n",
      "    The input shape to the graph\n",
      "\n",
      "dtype : str or dict of str to str\n",
      "    The input types to the graph\n",
      "\n",
      "freeze_params: bool\n",
      "    If this parameter is true, the importer will take any provided\n",
      "    onnx input values (weights, shapes, etc) and embed them into the relay model\n",
      "    as Constants instead of variables. This allows more aggressive optimizations\n",
      "    at compile time and helps in making models static if certain inputs represent\n",
      "    attributes relay would traditionally consider compile-time constants.\n",
      "\n",
      "op_type_dict: Dict[str, int]\n",
      "    Dictionary for span filling usage. If the name property of op was not set\n",
      "    op_type_dict will provide an alternative by combining literal op type with\n",
      "    its presenting order\n",
      "\u001b[0;31mFile:\u001b[0m           /media/pc/data/lxw/ai/tvm/python/tvm/relay/frontend/onnx.py\n",
      "\u001b[0;31mType:\u001b[0m           type\n",
      "\u001b[0;31mSubclasses:\u001b[0m     "
     ]
    }
   ],
   "source": [
    "GraphProto?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`GraphProto` 类是辅助类，用于处理从 `pb2.GraphProto` 复制到 Relay 表达式。\n",
    "\n",
    "该类有以下参数：\n",
    "- `shape`：一个字典，表示图的输入形状。这是一个可选参数。\n",
    "- `dtype`：一个字符串或字典，表示图的输入类型。如果是一个字典，则键是输入名称，值是对应的数据类型。\n",
    "- `freeze_params`：一个布尔值。如果为 `True`，则导入器会将提供的任何 ONNX 输入值（权重、形状等）嵌入到 Relay 模型中作为常量而不是变量。这允许在编译时进行更积极的优化，并在特定输入表示传统上被视为编译时常量的属性时使模型静态化。\n",
    "- `op_type_dict`：一个字典，用于 `span` 跨度填充使用。如果算子的名称属性未设置，则 `op_type_dict` 将通过将文字算子类型与呈现顺序相结合来提供替代方案。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "xin",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
